package dates;
import java.util.*;


public class Dates {
  
  static boolean isLeapYear(int yyyy)
  {
    GregorianCalendar myDate = new GregorianCalendar(yyyy,1,29);
    if(myDate.get(Calendar.MONTH) == 1)
      return true;
    else
      return false;
  }
  
  // remember Java months are zero based
  static int getDaysInMonth(int mm, int yyyy)
  {
  	GregorianCalendar myDate;
  	myDate = new GregorianCalendar(yyyy,mm,31);
  	if(myDate.get(Calendar.MONTH) == mm)
  	  return 31;
  	myDate = new GregorianCalendar(yyyy,mm,30);
  	if(myDate.get(Calendar.MONTH) == mm)
  	  return 30;
  	myDate = new GregorianCalendar(yyyy,mm,29);
  	if(myDate.get(Calendar.MONTH) == mm)
  	  return 29;
  	
  	return 28;
  }
  
 public static void main(String[] args) {
     
      
      System.out.println("\n");
      //GregorianCalendar myDate = new GregorianCalendar(2007,2,30); // should be Independence Day
      GregorianCalendar myDate = new GregorianCalendar(); // should be Independence Day
      System.out.println("Lets Print myDates values");
      System.out.println("YEAR: " + myDate.get(Calendar.YEAR));
      System.out.println("MONTH: " + myDate.get(Calendar.MONTH));
      System.out.println("WEEK_OF_YEAR: " + myDate.get(Calendar.WEEK_OF_YEAR));
      System.out.println("WEEK_OF_MONTH: " + myDate.get(Calendar.WEEK_OF_MONTH));
      System.out.println("DATE: " + myDate.get(Calendar.DATE));
      System.out.println("DAY_OF_MONTH: " + myDate.get(Calendar.DAY_OF_MONTH));
      System.out.println("DAY_OF_YEAR: " + myDate.get(Calendar.DAY_OF_YEAR));
      System.out.println("DAY_OF_WEEK: " + myDate.get(Calendar.DAY_OF_WEEK));
      System.out.println("DAY_OF_WEEK_IN_MONTH: " + myDate.get(Calendar.DAY_OF_WEEK_IN_MONTH));
      System.out.println("AM_PM: " + myDate.get(Calendar.AM_PM));
      System.out.println("HOUR: " + myDate.get(Calendar.HOUR));
      System.out.println("HOUR_OF_DAY: " + myDate.get(Calendar.HOUR_OF_DAY));
      System.out.println("MINUTE: " + myDate.get(Calendar.MINUTE));
      System.out.println("SECOND: " + myDate.get(Calendar.SECOND));
      System.out.println("MILLISECOND: " + myDate.get(Calendar.MILLISECOND));
      
      System.out.println("am i leap year: " + isLeapYear(2007));
      
      System.out.println("Days in Month : " + getDaysInMonth(1, 2012));
   }
   
   
}